package com.ziyia.layoutparams;

import androidx.appcompat.app.AppCompatActivity;

import android.content.pm.PackageInstaller;
import android.graphics.Color;
import android.os.Bundle;
import android.text.style.BackgroundColorSpan;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.material.textfield.TextInputEditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);

        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);

        LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setLayoutParams(layoutParams);
        linearLayout.setGravity(Gravity.CENTER);

        LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(200, 200);

        TextView textView = new TextView(this);
        textView.setText("年少有为");
        textView.setGravity(Gravity.CENTER);
        textView.setBackgroundColor(0xffff0000);
        textView.setTextColor(0xffffffff);

        linearLayout.addView(textView, layoutParams1);
        setContentView(linearLayout);

    }
}